package com.project.lk.nurseapp.remind;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.project.lk.nurseapp.R;
import com.project.lk.nurseapp.common.adapter.BaseRecycleViewAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class DateChooseAdapter extends BaseRecycleViewAdapter {
    List<DateItemBean> mList = new ArrayList<>();
    Context mContext;

    public DateChooseAdapter(List<DateItemBean> list, Context context) {
        this.mList = list;
        this.mContext = context;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_date_choose_layout, parent, false);
            ViewHolder viewHolder=new ViewHolder(view);
        return viewHolder;
    }

    public interface ItemCheckListener{
        void check(int position,boolean isChecked);
    }
    ItemCheckListener mListener;
    public void setCheckEvent(ItemCheckListener listener){
        this.mListener=listener;
    }
    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, final int position) {
        ViewHolder viewHolder = (ViewHolder) holder;
        viewHolder.itemCheck.setText(mList.get(position).getTitle());
        viewHolder.itemCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                mListener.check(position,isChecked);
            }
        });
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    static class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.item_check)
        CheckBox itemCheck;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
